﻿using System.Windows;

namespace PocketBook.Model
{
    public class LayoutMetrics : ILayoutMetrics
    {
        public const double MillimetersPerInch = 25.4;

        public LayoutMetrics()
        {
            PageSize = SizeOfA4;
        }

        public Size PageSize
        {
            get;
            set;
        }

        public Size SiteSize
        {
            get { return new Size(PageSize.Height / 4, PageSize.Width / 2); }
        }

        public static Size SizeOfA4
        {
            get { return MillimetersToPixels(new Size(210, 297)); }
        }

        public static Size MillimetersToPixels(Size size)
        {
            return new Size(MillimetersToPixels(size.Width), MillimetersToPixels(size.Height));
        }

        public static double MillimetersToPixels(double millimeters)
        {
            return (millimeters / MillimetersPerInch) * LogicalUnitsPerInch;
        }

        public static double LogicalUnitsPerInch
        {
            get { return 96d; }
        }
    }
}